<html>
<head><meta charset="utf-8"><title>token options · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html">token options</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="188248112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188248112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188248112">(Feb 14 2020 at 21:20)</a>:</h4>
<p>@matklad do you think it's reasonable if <code>WorldState::options</code> holds a <code>Vec</code> of <code>lsp_types::SemanticTokenTypes</code> and modifiers? In other words do we care if it knows about lsp types directly or should I store them as strings instead?</p>



<a name="188248151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188248151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188248151">(Feb 14 2020 at 21:21)</a>:</h4>
<p>at some point we need the server to compare its list of supported token types/modifiers with the clients and use that as the list to generate tokens and modifiers from</p>



<a name="188248266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188248266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188248266">(Feb 14 2020 at 21:22)</a>:</h4>
<p>I would probably put that info in <code>conv.rs</code></p>



<a name="188248305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188248305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188248305">(Feb 14 2020 at 21:23)</a>:</h4>
<p>I think we need</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">token_legend</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="nc">LspLegend</span><span class="w"></span>
</pre></div>


<p>and just the usual <code>ConvWith</code> impl? Ie, we don't need to hold any state apparently?</p>



<a name="188248532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188248532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188248532">(Feb 14 2020 at 21:25)</a>:</h4>
<p>Well... I think you need to loop through the server tokens and compare them with what the client supports and use that as the legend to send back from the server capabilities: <a href="https://github.com/microsoft/vscode-languageserver-node/blob/master/testbed/server/src/server.ts#L111" target="_blank" title="https://github.com/microsoft/vscode-languageserver-node/blob/master/testbed/server/src/server.ts#L111">https://github.com/microsoft/vscode-languageserver-node/blob/master/testbed/server/src/server.ts#L111</a></p>



<a name="188248700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188248700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188248700">(Feb 14 2020 at 21:27)</a>:</h4>
<p>Hm, I would think this is advisory? Like, the server <em>could</em> adapt its tokens to the client ones, but it doesn't have to?</p>



<a name="188249133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188249133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188249133">(Feb 14 2020 at 21:33)</a>:</h4>
<p>That's not how I'm reading the code but I do see in the comments that describe the encoding that "at index <code>5*i+3</code> - <code>tokenType</code>: will be looked up in <code>SemanticTokensLegend.tokenTypes</code>" so maybe you are right. It would certainly make it easier and I wouldn't have to deal with client caps</p>



<a name="188249168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/token%20options/near/188249168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/token.20options.html#188249168">(Feb 14 2020 at 21:33)</a>:</h4>
<p>I'll go with that</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>